1. Field of the Invention
The present invention relates to video encoders and decoders. Particularly, the present invention relates to video encoders and decoders adapted to both of motion vector prediction and DC/AC prediction.
2. Description of the Related Art
Inter-frame and intra-frame predictions are two major video encoding techniques. The inter-frame prediction is a video encoding technique based on the similarities between consecutive frames in the video sequence. As long as there is no rapid change in a moving picture, many portions of the moving picture are almost unchanged between the consecutive frames. Therefore, an efficient video encoding can be achieved by selectively encoding the data representing changes in the consecutive frames. The motion estimation is a typical video encoding technique based on inter-frame prediction. The motion estimation involves calculating motion vectors, which are representative of the changes between the current and referenced frames, and encoding the motion vectors.
The intra-frame prediction, on the other hand, is a video encoding technique based on strong correlation between grayscale levels of adjacent pixels within a single frame. The discrete cosine translation (DCT) is a typical video encoding technique based on the intra-frame prediction.
Many video encoding techniques exploits both of the inter-frame and intra-frame predictions. For example, the MPEG4 SP (Moving Picture Experts Group 4 Simple Profile) encoding expresses a moving image with I-VOPs (Video Object Plane) generated by using only the intra-frame prediction, and P-VOPs generated by using the inter-frame prediction and the forward intra-frame prediction. Furthermore, the MPEG4 ASP (Advanced Simple Profile) encoding expresses moving images with B-VOP and S-VOP (sprite VOP) generated by using the bidirectional inter-frame prediction and the intra-frame prediction in addition to I-VOP and P-VOP. It should be noted that the MPEG4 specification refers to the video encoding based on the intra-frame prediction as the intra-mode encoding, and to the video encoding based on the inter-frame prediction as the inter-mode encoding.
The motion vector prediction is one of the video encoding techniques used in the inter-frame prediction. The motion vector prediction is a technique for further compressing the image by the differential encoding of the motion vectors calculated by the motion estimation.
On the other hand, the DC/AC prediction is one of the image encode techniques used in the intra-frame prediction. The DC/AC prediction is a technique that compresses an image by encoding a DC component and AC components of the image by differential encoding. When the DCT is used in the intra-frame prediction, a DC coefficient and AC coefficients calculated by the DCT are encoded by differential encoding.
The MPEG4 exploits both of the motion vector prediction and the DC/AC prediction. The following is a description of the procedures of the motion vector prediction and the DC/AC prediction, specified in the MPEG4.
The motion vector prediction and the DC/AC prediction specified in the MPEG4 are based on the fact that each frame has a 4:2:0 luminance format shown in FIG. 1. The MPEG4 4:2:0 luminance format divides one frame into macro blocks (MB) each composed of a luminance macro block of 16×16 pixels and two chrominance blocks of 8×8 pixels, and further divides each luminance macro block into four 8×8 pixel blocks arranged in two rows and two columns. When each frame is composed of 720×480 pixels, for example, the frame is each composed of luminance macro blocks arranged in 30 rows and 45 columns, in other words, composed of blocks arranged in 60 rows and 90 columns. A line of macro blocks arranged in the horizontal direction of the frame may be referred to as the macro block line, and a line of blocks arranged in a line in the horizontal direction may be referred to as the block line. The MPEG4 specifies that the motion vector prediction and the DC/AC prediction are performed in units of blocks.
FIGS. 2A to 2D are schematic views of the procedure of the motion vector prediction specified in the MPEG4. According to the MPEG4, the motion vector prediction of a current block within a current macro block is performed by referring to the motion vectors associated with three reference blocks; the current block is referred by a symbol “MV”, and the reference blocks are referred by symbols “MV1”, “MV2” and “MV3”, respectively, in FIGS. 2A to 2D. The motion vector prediction specified in MPEG4 determines the median of the motion vectors associated with the three reference blocks, and defines the difference between the determine median and the motion vector of the current block as the motion vector difference.
The motion vector difference is accompanied by control data indicating which reference block is used for generating the motion vector difference (that is, indicating which referenced block is adopted as the median of the three referenced blocks). The control data is used to reproduce the original motion vector from the motion vector difference, that is, to perform the inverse vector prediction. The inverse vector prediction is achieved by adding the motion vector difference to the motion vector of the reference block indicated by the control data.
The relative positioning between the current block and the reference blocks is different according to the position of the current block within the current macro block. As shown in FIG. 2A, when the current block MV is located on the upper left of the current macro block, a block MV1 adjacent to the left of the current block MV, a block MV2 adjacent to the top of the current block MV, and a block MV3 located away from the block MV2 by two blocks on the right are used as the reference blocks. When the current block MV is located on the upper right of the current macro block, as shown in FIG. 2B, a block MV1 adjacent to the left of the current block MV, a block MV2 adjacent to the top of the current block MV, and a block MV3 adjacent to the right of the block MV2 are used as the reference blocks. When the current block MV is located on the lower left of the current macro block, as shown in FIG. 2C, a block MV1 adjacent to the left of the current block MV, a block MV2 adjacent to the top of the current block MV, and a block MV3 adjacent to the right of the block MV2 are used as the reference blocks. Finally, when the current block MV is located on the lower right of the macro block, as shown in FIG. 2D, a block MV1 adjacent to the left of the current block MV, a block MV2 adjacent to the top of the block MV1, and a block MV3 adjacent to the top of the current block MV are used as the reference blocks.
It should be noted that, when a specific block to which the motion vector is not given is selected as one of the reference blocks, the motion vector prediction for the current block MV excludes the specific block in the determination of the motion vector difference. Referring to FIG. 2A, for example, the difference motion vector associated with the current block MV is calculated from only the motion vectors of the reference blocks MV2 and MV3, when the motion vector is not calculated for the reference block MV1. Such situation may occur, when the macro block adjacent to the current macro block is encoded by the intra-mode encoding, or when the current macro block is located on the left end of the frame.
As understood from FIGS. 2A to 2D, the motion vector prediction for four blocks within a current macro block requires motion vectors of five blocks around the current macro block located in the position shown in FIG. 2E (that is, two blocks arranged on the left of the current macro block and three blocks on the block line adjacent to the top of the current macro block), in addition to the motion vectors of the four blocks of the current macro block. The motion vector prediction requires temporarily storing the motion vectors of the above-described five blocks in a work area.
Correspondingly, inverse motion vector prediction for a current macro block requires storing previously-reproduced motion vectors of the reference blocks associated with the respective current blocks within the current macro block, in a work area. The inverse vector prediction to the current macro block requires temporarily storing the previously-reproduced motion vectors of the five blocks in the work area, since the reference blocks are selected from the above-described five blocks.
On the other hand, FIGS. 3A to 3D are schematic views of the procedure of the DC/AC prediction specified in the MPEG4. According to the MPEG4, the DC/AC prediction of a current block of n current macro block is performed by referring to DC and AC coefficients associated with three reference blocks. In the DC/AC prediction, differently from the motion vector prediction, the relative positions between the current block and the three reference blocks is not dependent on the position of the current block within the macro block. As shown in FIGS. 3A to 3D, a block A adjacent to the left of the current block X, a block B adjacent to the top of the block A, and a block C adjacent to the top of the current block X are used as the reference blocks in the DC/AC prediction for the current block X, regardless of the position of the current block X within the current macro block.
The block used for calculating DC and AC coefficient difference data for the current-block is selected from the reference blocks A and C on the basis of the DC coefficients calculated for the reference blocks A, B and C. The difference between the DC coefficients of the selected block and the current block X is determined as the DC coefficient difference data associated with the current block X, the respective differences between the AC coefficients of the selected block and the current block X are determined as the AC coefficient difference data.
It should be noted that, when a certain block to which DC and AC coefficients are not given is selected as one of the reference blocks, the DC/AC prediction for the current block X excludes the certain block in the determination of the DC and AC coefficient difference data. Referring to FIG. 3A, when the DC coefficient and the AC coefficients are not given to the reference block B, for example, the DC and AC coefficient difference data associated with the current block X are calculated from the DC coefficients and the AC coefficients of only the reference blocks A and C. Such situation may occur, when the macro block adjacent to the current macro block is encoded by the inter-mode encoding or when the current macro block is located on the left end of the image.
The calculated DC and AC coefficient difference data are attached with control data indicating which reference block is used for calculating the DC and AC coefficient difference data. The control data is used to perform inverse DC/AC prediction for reproducing the original DC and AC coefficients from the DC and AC coefficient difference data. The inverse DC/AC prediction is achieved by adding the DC and AC coefficient difference data to the DC and AC coefficients of the reference block indicated by the control data, respectively.
As understood from FIGS. 3A to 3D, the DC/AC prediction for four blocks within an current macro block requires the sets of DC and. AC coefficients associated with five blocks around the current macro block located in the position shown in FIG. 3E (that is, two blocks arranged on the left of the current macro block and three blocks of the block line adjacent to the top the current macro block), in addition to the set of the DC and AC coefficients of four blocks within the current macro block. The AC/DC prediction requires temporarily storing the DC and AC coefficients of the above-described five blocks in a work area.
Correspondingly, inverse DC/AC prediction for a current macro block requires storing the previously-reproduced DC/AC coefficients of the reference blocks associated with the respective current blocks included within the current macro block, in the work area. The inverse DC/AC prediction for the current macro block requires temporarily store the DC and AC coefficients reproduced for the five blocks in the work area, since the reference blocks are selected from the above-described five blocks.
One of the important requirements imposed on a video encoder and decoder is to achieving encoding and decoding of moving images with reduced hardware, especially in terms of the capacity of a memory used as a work area in the encoding and decoding. It is important for manufacturers of video encoders and decoders to develop efficient hardware implementations, since many video encoding specifications, such the MPEG4 specification do not specify hardware implementations for encoding and decoding.
Japanese Laid-Open Patent Application No. 2004-274411A, for example, discloses a technique for reducing the capacity of a motion vector memory used as a work area of the motion vector prediction down to the capacity corresponding to the data size of motion vectors associated with only one macro block line. In this technique, the capacity of the motion vector memory is reducing by appropriately transferring motion vectors within the motion vector memory.
Additionally, Japanese Laid-Open Patent Application No. 2002-118853A discloses a video decoder for reducing the capacity of a memory area for storing the referenced DC/AC coefficients for the DC/AC prediction, down to the capacity corresponding to the data size necessary for the DC/AC prediction of one macro block line. In this technique, the capacity of the memory area is reduced by copying the reproduced DC and AC coefficients to a line storage portion.
However, the prior arts suffer from a problem that the overall capacity of the memory area required for achieving both of the motion vector prediction and the DC/AC prediction is not sufficiently reduced. The prior arts also suffer from a problem that the overall capacity of the memory area required for the inverse motion vector prediction and the inverse DC/AC prediction is not sufficiently reduced. Even when both of the above-described two prior arts are used, the overall capacity of the memory area required for the motion vector prediction and the DC/AC prediction is reduced only down to the capacity required for the predictions of two macro block lines. The same applies to the inverse motion vector prediction and the inverse DC/AC prediction.